import fetch from 'common/src/utils/fetch';

/**
 * 教师个人课表
 */
function findTeacherTimetable(calendarId, teacherCode) {//研究生
    return fetch({
        url:
            '/api/electionservice/reportManagement/findTeacherTimetable?calendarId=' +
            calendarId +
            '&teacherCode=' +
            teacherCode,
        method: 'get'
    });
}
/**
 * 教师个人课表
 */
function findTeacherTimetableNew(calendarId, teacherCode) {//本科生研究生
    return fetch({
        url:
            '/api/electionservice/reportManagement/findTeacherTimetableNew?calendarId=' +
            calendarId +
            '&teacherCode=' +
            teacherCode,
        method: 'get'
    });
}
//研究生教师个人课表
function findGraduateTeacherTimetable(calendarId, teacherCode,projectId) {//研究生列表
    return fetch({
        url:
            '/api/electionservice/reportManagement/findTeacherTimetable2?calendarId=' +
            calendarId +
            '&teacherCode=' +
            teacherCode+
            '&projectId='+projectId,
        method: 'get'
    });
}
function findGraduateTeacherTimetable2(calendarId, teacherCode) {//研究生列表
    return fetch({
        url:
            '/api/electionservice/reportManagement/findTeacherTimetable2?calendarId=' +
            calendarId +
            '&teacherCode=' +
            teacherCode,
        method: 'get'
    });
}

/**
 * 导出所有教师课表
 */
function exportTeachers(data) {
    return fetch({
        url: '/api/electionservice/reportManagement/exportTeacher',
        method: 'post',
        data: data
    });
}

/**
 *
 * 查询是否导出完成
 */
function exportStatus(key) {
    return fetch({
        url: '/api/electionservice/reportManagement/result/'+key,
        method: 'get'
    });
}
//研究生教师个人课表导出
function exportGraduateTeacherTimetabPdf(params,projectId){
    if(projectId == 1) {
        params.projectId =  1
    }
    if(projectId == 2) {
        params.projectId =  2
    }
    if(!projectId) {
        params.projectId = ''
    }
    let query = '?';
    for (let key in params) {
        query += key;
        query += '=';
        query += params[key];
        query += '&';
    }
    return '/api/electionservice/reportManagement/exportTeacherTimetabPdf'+query.substring(0, query.length - 1)
}

export default {
    findAllTeacherTimeTableUrl: '/api/electionservice/reportManagement/findAllTeacherTimeTable',
    graduateFindAllTeacherTimeTableUrl:'/api/electionservice/reportManagement/findTeacherTimeTableByRole',
    findTeacherTimetable: findTeacherTimetable,
    exportTeachers:exportTeachers,
    exportStatus:exportStatus,
    findGraduateTeacherTimetable,//研究生教师个人课表
    exportGraduateTeacherTimetabPdf,//导出研究生教师个人课表
    findGraduateTeacherTimetable2,
    findTeacherTimetableNew
};
